package com.upbos.upm.app;

import com.upbos.upm.entity.App;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <b>Application name：</b> AppService.java <br>
 * <b>Application describing: 应用管理Service</b> <br>
 * <b>Copyright：</b> Copyright &copy; 2015-2021 yideb.com 版权所有。<br>
 * <b>Company：</b> yideb.com <br>
 * <b>Date：</b> 2019年07月11日 17:09 <br>
 * <b>author：</b> <a href="mailto:wangjz@miyzh.com"> Jason </a>
 * <b>version：</b>V5.0.0
 */
@Service
public class AppService {

	@Resource
	private AppDao appDao;

	/**
	 * 查询应用列表
	 * @param name 应用名称
	 * @return 应用列表
	 */
	public List<App> listApp(String name) {
		return appDao.listApp(name);
	}

	/**
	 * 保存应用信息
	 * @param app 应用信息
	 */
	@Transactional(rollbackFor = Exception.class)
	public void saveApp(App app) {
	    if(app.getId() == null || "".equals(app.getId())) {
	    	// 插入应用信息
	    	appDao.insertApp(app);
        }else {
	    	// 更新应用信息
            appDao.updateApp(app);
        }
	}

	/**
	 * 根据应用ID删除应用信息
	 * @param app 应用id
	 */
	@Transactional(rollbackFor = Exception.class)
	public void deleteApp(App app) {
		appDao.deleteApp(app);
	}
}
